#pragma once

#include <YSimpleSystem/Interface.h>
#include <YSimpleNetwork/YSimpleNetwork.h>
#include <WinSock2.h>
#include <string>


namespace ysimple_network
{
	class YEndPoint;
	struct IConnectCallback;
	struct IAcceptCallback;
	struct ISendCallback;
	struct IRecvCallback;
	struct IDisconectCallback;
	struct ICancelIOCallback;

	struct ITCPSession
		: public ysimple_system::Interface
	{
		virtual bool				init(IDisconectCallback& disconnectCallback) = 0;
		virtual bool				bind(const YEndPoint& endPoint) = 0;
		virtual SOCKET			getSocket() const = 0;
		virtual bool				accept( ITCPSession& listenSession, IAcceptCallback& callback) = 0;
		virtual bool				listen(const YEndPoint& endPoint, int backlog) = 0;
		virtual bool				connect(const std::string& ip, WORD port, IConnectCallback& callback) = 0;	
		virtual bool				send(PACKET_SPTR packet, ISendCallback& callback) = 0;
		virtual bool				resend(ISendCallback& callback) = 0;
		virtual bool				recv(IRecvCallback& callback) = 0;
		virtual bool				disconnect() = 0;
		virtual void				shutdown() = 0;
		virtual void				close() = 0;
		virtual bool				reused() const = 0;
		virtual bool				cancel(ICancelIOCallback& callback) = 0;
		virtual void				addRef() = 0;
	};

}

